package com.examsystem.controller;

import com.examsystem.service.ExcelService;
import lombok.SneakyThrows;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.InputStream;

/**
 * @author 86134
 */
@Controller
@RequestMapping("/excel")
public class ExcelController {

    @Resource
    private ExcelService excelService ;

/*
教师端代码
 */

    @SneakyThrows
    @RequestMapping("/import")
    @ResponseBody
    @PreAuthorize("hasAuthority('excel:import')")
    public int importExcelQuestion(MultipartFile file,String filename, InputStream is){
        String s = excelService.uploadExcel(file);
        if (s != null) {
            //导入成功
            return 1;
        }
        //未导入或者导入失败
        return 0;
    }


}
